﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using NS_DBOP;

public partial class Flow_FwTypePub : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!Page.IsPostBack)
        {
            string id = Request.QueryString["id"];

            if (id != null)
            {

                string name = new DBoperate().ExecuteScalar("select Name from FlowType where ID=" + id).ToString();
                this.txtTypeName.Text = name;
            }
        }
        
    }
    protected void btnSave_Click(object sender, EventArgs e)
    {
        string typename = this.txtTypeName.Text;

        int result = 0;
        if (Request.QueryString["id"] != null)
        {
            string id = Request.QueryString["id"];
            result = new DBoperate().ExecuteUpdate("update FlowType set Name='" + typename + "' where ID=" + id);
            if (result > 0)
            {
                Response.Write("<script language=javascript>alert('保存成功！');window.location.href='FlTypeM.aspx'</script>");
            }
            else
            {
                Response.Write("<script language=javascript>alert('保存失败！')</script>");
            }

        }
        else
        {
            result = new DBoperate().ExecuteUpdate("insert into  FlowType (Name) values('" + typename + "')");
            if (result > 0)
            {
                Response.Write("<script language=javascript>alert('保存成功！');window.location.href='FlTypeM.aspx'</script>");
            }
            else
            {
                Response.Write("<script language=javascript>alert('保存失败！')</script>");
            }
        }
    }
}
